package com.oss.controller.oss;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oss.common.BaseResponse;
import com.oss.dto.oss.purchasecourses.*;
import com.oss.entity.oss.PurchaseCourses;
import com.oss.service.oss.PurchaseCoursesService;
import com.oss.vo.oss.purchasecourses.PurchaseCoursesVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 购课管理
 */
@RestController
@RequestMapping("/purchaseCourses")
public class PurchaseCoursesController {
    @Autowired
    PurchaseCoursesService purchaseCoursesService;

    @PostMapping("/selectByPage")
    public BaseResponse<IPage<PurchaseCoursesVO>> selectByPage(@RequestBody @Valid PurchaseCoursesPageDto dto){
        return BaseResponse.success(purchaseCoursesService.selectByPage(dto));
    }
    @PostMapping("/add")
    public BaseResponse<String> add(@RequestBody @Valid PurchaseCoursesAddDto dto){
        return BaseResponse.success(purchaseCoursesService.add(dto));
    }
    @PostMapping("/update")
    public BaseResponse<String> update(@RequestBody @Valid PurchaseCoursesUpdateDto dto){
        return BaseResponse.success(purchaseCoursesService.updateData(dto));
    }
    @PostMapping("/delete")
    public BaseResponse<String> delete(@RequestBody @Valid PurchaseCoursesDeleteDto dto){
        return BaseResponse.success(purchaseCoursesService.delete(dto));
    }
    @PostMapping("/getByID")
    public BaseResponse<PurchaseCourses> getByID(@RequestBody @Valid PurchaseCoursesGetByIDDto dto){
        return BaseResponse.success(purchaseCoursesService.getById(dto.getId()));
    }
}